package com.zyh.kaoshi.test2;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

/**
 * @Author zyh
 * @Date 2024/8/3 12:12
 * @Description
 */

public class Test2 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Map<String ,Integer> map=new HashMap();
        map.put("zyh",99);
        map.put("cxk",59);
        map.put("dz",19);
        map.put("wy",61);
        Set<Map.Entry<String, Integer>> entries = map.entrySet();
        for (Map.Entry<String, Integer> entry : entries) {
            System.out.println(entry.getKey()+"--"+entry.getValue());
        }
        System.out.println("请输入要修改的学生姓名");
        String name = input.next();
        boolean flag=false;
        Set<String> keySet = map.keySet();
        for (String key : keySet) {
            Integer value = map.get(key);
            if (key.equals(name)){
                flag=true;
                break;
            }
        }
        if (flag){
            System.out.println("请输入要修改的成绩");
            int score = input.nextInt();
            map.put(name,score);
            System.out.println("修改成功");
            Set<Map.Entry<String, Integer>> entries1 = map.entrySet();
            for (Map.Entry<String, Integer> entry : entries1) {
                System.out.println(entry.getKey()+"--"+entry.getValue());
            }
        }
        else {
            System.out.println("查无此人，修改失败");
        }
    }
}
